Updated functions for best performance [3]