Made script more dynamic/readable

Now based on constants rather than magic numbers