How to fix runtime error?