Cleaned logic up a bit more