Added some useful functions
Better replacement code