using apply functions