Remove redundant code and add define