added refresh, put data calls in function