fixed mahys code