modified for potentially cleaner code!