fixing runtime error