Added 'delete' functionality, modified conditions for consistency