Added error checking for empty input
Removed unsed imports