Is there a way that we can have this but without repeating the code?