Updated to remove implicit type conversions

Makes the logic a little more clear and improves code quality.