Works better now

Added rep function