added deletion of posts and modified code to make it more modular