Cleaned up logic a bit after review