wesam's original code working here