Refactor more code for cards