Updated insert function and added perculate functions for swapping