magic numbers removed, types defined