Remove duplicate code as suggested by Ryan