changed #define constant to const
formatted loops