Begun implementation of last function