Tidied up code slightly, remove empty() calls where not required