Implemented a contrast algorithm