Fixing function name
Rearranging code