modified implementation