Can you extract out these codes as constants or methods?