Incorporated more variables

Tried to eliminate as many "magic numbers" as possible