completed and tested smArray function