added isEmpty method
fixed bugs