generalising the logic