fixed return stmts and misc bugs
removed scratchpad