Implemented the Fast algorithm