Fix ugly code